﻿<Page
    x:Class="AuthenticationExample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:AuthenticationExample"
    xmlns:data="using:AuthenticationExample.Data"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
        <x:String x:Key="AppName">Authentication Example</x:String>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.DataContext>
            <data:ViewModel/>
        </Grid.DataContext>
        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" 
                       VerticalAlignment="Bottom"
                       Margin="30,0,30,40"
                       Grid.Column="1" IsHitTestVisible="false"/>
        </Grid>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="12"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <TextBlock Text="Authentication Status:" Style="{StaticResource HeaderTextBlockStyle}" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0 0 0 40"
                       TextTrimming="CharacterEllipsis"/>
            <TextBlock Text="{Binding AuthenticationStatus}" TextWrapping="Wrap" Grid.Column="1" Style="{StaticResource HeaderTextBlockStyle}" Margin="12 0 0 0"/>
            <TextBlock Text="Email from Identity:" Style="{StaticResource HeaderTextBlockStyle}" Margin="12 0 0 0" Grid.Row="1"/>
            <TextBlock Text="{Binding Email}" Grid.Column="1" Grid.Row="1" Style="{StaticResource HeaderTextBlockStyle}" Margin="12 0 0 0"/>
            <TextBlock Text="Choose Authentication Provider:" Style="{StaticResource HeaderTextBlockStyle}" Margin="12 0 0 0" Grid.Row="3"/>
            <ComboBox ItemsSource="{Binding AuthenticationTypes}" DisplayMemberPath="Name" Grid.Row="3" Grid.Column="1" SelectedItem="{Binding SelectedType, Mode=TwoWay}"
                      Margin="12 0 0 0" HorizontalAlignment="Left" Width="200"></ComboBox>
            <StackPanel Grid.Row="4" Grid.Column="1" Orientation="Horizontal" Margin="12">
                <Button Content="Sign On" Margin="12" Command="{Binding}"/>
                <Button Content="Sign Out" Margin="12" Command="{Binding}" CommandParameter="signout"/>
            </StackPanel>
            <ListView Grid.Row="5" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5"
                      ItemsSource="{Binding Console}" SelectedItem="{Binding ConsoleItem, Mode=TwoWay}"
                      SelectionChanged="Selector_OnSelectionChanged">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}" Foreground="Gray" Style="{StaticResource BaseTextBlockStyle}" TextWrapping="Wrap"></TextBlock>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </Grid>
    </Grid>
</Page>
